//
//  CarModuleApi.m
//  QinghaiTourism
//
//  Created by QianXiaoShu on 16/3/28.
//  Copyright © 2016年 QianXiaoShu. All rights reserved.
//

#import "CarModuleApi.h"

@implementation CarModuleApi

//获取车辆类型
+ (void)getCarTypeListcompletion:(AICompletionBlock)block{

    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
    
    NSString *unEncode = [NSString stringWithFormat:@"server=app/driverCarInfo/getCarTypeList"];
    
    NSString *encodeKey =  [DeviceUtility encryptUseDES:unEncode key:YQH_DESEncrypt_Key];
    
    [dic setObject:encodeKey forKey:@"key"];
    
    
    
    [CarModuleApi startRequest:_getCarTypeList params:dic completion:block];

}



/*
 我要认证
 cardnum:身份证号
 driveage: 驾龄
 cartypeId:车辆类型id
 carnum： 车牌号
 fileName0-4 :0正面 1:车辆图片 2；身份证反面 3:驾驶证 4:行驶证
 */
+ (void)renZhengWithId:(NSString *)driverId phone:(NSString *)phone cardnum:(NSString *)cardnum driveage:(NSString *)driveage carname:(NSString *)carname cartypeId:(NSString *)cartypeId carnum:(NSString *)carnum fileName0:(NSString *)fileName0 fileName1:(NSString *)fileName1 fileName2:(NSString *)fileName2 fileName3:(NSString *)fileName3 fileName4:(NSString *)fileName4 completion:(AICompletionBlock)block{
   
    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
    NSString *carTypeStr = [cartypeId isEqualToString:@"经济型"]?@"0":[cartypeId isEqualToString:@"豪华型"]?@"1":[cartypeId isEqualToString:@"舒适型"]?@"2":@"3";
    
    NSString *unEncode = [NSString stringWithFormat:@"server=app/driverCar/authentCar&driverId=%@&phone=%@&cardnum=%@&driveage=%@&carname=%@&cartypeId=%@&carnum=%@&fileName0=%@&fileName1=%@&fileName2=%@&fileName3=%@&fileName4=%@",driverId,phone,cardnum,driveage,carname,carTypeStr,carnum,fileName0,fileName1,fileName2,fileName3,fileName4];
    
    NSString *encodeKey =  [DeviceUtility encryptUseDES:unEncode key:YQH_DESEncrypt_Key];
    
    [dic setObject:encodeKey forKey:@"key"];
    
    
    
    [CarModuleApi startRequest:_authentCarOfAction params:dic completion:block];



}


//获取车辆信息
+ (void)getcarInfoWithDriverId:(NSString *)driverId completion:(AICompletionBlock)block{
   
    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
    
    NSString *unEncode = [NSString stringWithFormat:@"server=app/driverCar/myCarInfo&driverId=%@",driverId];
    
    NSString *encodeKey =  [DeviceUtility encryptUseDES:unEncode key:YQH_DESEncrypt_Key];
    
    [dic setObject:encodeKey forKey:@"key"];
    
    
    
    [CarModuleApi startRequest:_myCarInfoOfAction params:dic completion:block];
    


}



//修改商业险到期时间
+ (void)changeBusinessWithCarInfoId:(NSString *)carInfoId business:(NSString *)business completion:(AICompletionBlock)block{

    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
NSString *businesstime =  [QHTools timeInterverStringFromTimeString:business];
    
    NSString *unEncode = [NSString stringWithFormat:@"server=app/driverCar/modifyBusiness&carInfoId=%@&business=%@",carInfoId,businesstime];
    
    NSString *encodeKey =  [DeviceUtility encryptUseDES:unEncode key:YQH_DESEncrypt_Key];
    
    [dic setObject:encodeKey forKey:@"key"];
    
    
    
    [CarModuleApi startRequest:_modifyBusinessOfAction params:dic completion:block];

}



//获取车辆保养项目
+ (void)completion:(AICompletionBlock)block{
   
    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
    
    NSString *unEncode = [NSString stringWithFormat:@"server=app/driverCar/getAllMaintainProject"];
    
    NSString *encodeKey =  [DeviceUtility encryptUseDES:unEncode key:YQH_DESEncrypt_Key];
    
    [dic setObject:encodeKey forKey:@"key"];
    
    
    
    [CarModuleApi startRequest:_getAllMaintainProject params:dic completion:block];



}


/*
 添加车辆保养记录
 projectId:服务项目id
 mainintinTime：添加时间
 
 */

+ (void)addCarMaintainRecord:(NSString *)driverId projectId:(NSString *)projectId mainintinTime:(NSString *)mainintinTime completion:(AICompletionBlock)block{

    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
    
  
   NSString *time =  [QHTools timeInterverStringFromTimeString:mainintinTime];
    
    
    NSString *unEncode = [NSString stringWithFormat:@"server=app/driverCar/addCarmaintainrecord&driverId=%@&projectId=%@&mainintinTime=%@",driverId,projectId,time];
    
    NSString *encodeKey =  [DeviceUtility encryptUseDES:unEncode key:YQH_DESEncrypt_Key];
    
    [dic setObject:encodeKey forKey:@"key"];
     
    [CarModuleApi startRequest:_addCarmaintainrecord params:dic completion:block];
    


}



/*
 //更换我的车辆
 cartypeId:车辆类型ID
 fileName0：行驶证
 fileName1: 车辆图片
 
 */
+ (void)changeMyCarWithId:(NSString *)driverId carname:(NSString *)carname cartypeId:(NSString *)cartypeId carnum:(NSString *)carnum fileName0:(NSString *)fileName0 fileName1:(NSString *)fileName1 completion:(AICompletionBlock)block{

    
    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
    
    NSString *unEncode = [NSString stringWithFormat:@"server=app/driverCar/vehicleReplacement&driverId=%@&carname=%@&cartypeId=%@&carnum=%@&fileName0=%@&fileName1=%@",driverId,carname,cartypeId,carnum,fileName0,fileName1];
    
    NSString *encodeKey =  [DeviceUtility encryptUseDES:unEncode key:YQH_DESEncrypt_Key];
    
    [dic setObject:encodeKey forKey:@"key"];
    
    
    
    [CarModuleApi startRequest:_vehicleReplacement params:dic completion:block];


}

//获取司机车辆图片
+(void)getDriverImgListWithDriverID:(NSString *)driverId completion:(AICompletionBlock)block{

    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
    
    NSString *unEncode = [NSString stringWithFormat:@"server=app/driverCarPrcture/getDriverImgList&driverId=%@",driverId];
    
    NSString *encodeKey =  [DeviceUtility encryptUseDES:unEncode key:YQH_DESEncrypt_Key];
    
    [dic setObject:encodeKey forKey:@"key"];
    
    
    [CarModuleApi startRequest:_getDriverImgList params:dic completion:block];
    

}
//删除司机车辆图片
+(void)deletePictureWithPictureId:(NSString *)pictureId completion:(AICompletionBlock)block {
    
    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
    
    NSString *unEncode = [NSString stringWithFormat:@"server=app/driverCarPrcture/deletePicture&pictureId=%@",pictureId];
    
    NSString *encodeKey =  [DeviceUtility encryptUseDES:unEncode key:YQH_DESEncrypt_Key];
    
    [dic setObject:encodeKey forKey:@"key"];
    
    
    [CarModuleApi startRequest:_deletePicture params:dic completion:block];
    

}

#pragma mark ---- 发起请求

+ (AIRequest *) startRequest:(NSString *)method params:(NSDictionary *)param completion:(AICompletionBlock)block {
    
    AIRequest *request = [AIRequest startWithRequestToURL:nil
                                                   method:method
                                                jsonParam:param
                                                  encrypt:NO
                                                    block:block];
    request.module = _carModuleName;
    
    return request;
}



@end
